/*****************************************************************************
*
*  PROJECT:     SlipStream
*               (CVector3 - 3D Vector Class)
*  LICENSE:     GNU General Public License v3 - http://www.gnu.org/licenses/gpl.html

*  DEVELOPERS:  Philip Farquharson	<B00137077@studentmail.uws.ac.uk>
*				John Gray			<B00145524@studentmail.uws.ac.uk>		
*				Zohaib Bhatti		<B00104280@studentmail.uws.ac.uk>
*				Euan Hislop			<B00138636@studentmail.uws.ac.uk>
*
*****************************************************************************/

#ifndef CVECTOR3
#define CVECTOR3

#include <cmath>

class CVector3
{
private:
	float x, y, z;

public:
	//////////////////////////////////////////////////////////
	//					Constructors						//
	//////////////////////////////////////////////////////////
	CVector3() : x(0), y(0), z(0) { }
	CVector3( float a, float b, float c ) : x(a), y(b), z(c) { }

	//////////////////////////////////////////////////////////
	//					Accessor Methods					//
	//////////////////////////////////////////////////////////
	const float& getX () const				{ return x; }
	void  setX ( float fX )					{ x = fX; }

	const float& getY () const				{ return y; }
	void  setY ( float fY )					{ x = fY; }

	const float& getZ () const				{ return z; }
	void  setZ ( float fZ )					{ x = fZ; }

	//////////////////////////////////////////////////////////
	//				Operator overloads						//
	//////////////////////////////////////////////////////////

	// comparison
	bool operator== ( CVector3& vec );

	// negation
	CVector3 operator- ();

	// assignment
	const CVector3& operator= ( const CVector3& vec );

	// addition
	const CVector3& operator+= ( const CVector3& vec );
	
	// subtraction
	const CVector3& operator-= ( const CVector3& vec );

	// scaling up
	const CVector3& operator*= ( const float& fScale );

	// scaling down
	const CVector3& operator/= ( const float& fScale );

	// addition w/o modification
	const CVector3 operator+ ( const CVector3& vec ) const;

	// subtraction w/o modification
	const CVector3 operator- ( const CVector3& vec ) const;

	// scaling up w/o modification
	const CVector3 operator* ( const float& fScale ) const;

	// scaling down w/o modification
	const CVector3 operator/ ( const float& fScale ) const;

	
	//////////////////////////////////////////////////////////
	//					Class Functions						//
	//////////////////////////////////////////////////////////
	
	// dot product
	const float dot ( const CVector3& vec ) const;

	// vector length
	const float length() const;

	// unit vector
	const CVector3 unit() const;

	// normalize - make this vector a unit vector
	void normalize ( void );

	// update this vector
	void update ( const CVector3& vec );
	void update ( float fX, float fY, float fZ);
};
#endif